<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
 var each = function (ary, callback) {
     for(var i = 0, l = ary.length ; i<l;i++){
         if(callback(i,ary[i])===false){
             break
         }
     }
 }
 each([1,2,3,4,5,6],function (i, o) {
     if(o>4){
         return false
     }
     console.log(o);
 })
</script>
</body>
</html>